package org.basis.enhance.async.init.configuration;

import org.basis.enhance.async.init.listener.AsyncTaskExecutionListener;
import org.basis.enhance.async.init.processor.AsyncInitBeanFactoryPostProcessor;
import org.basis.enhance.async.init.processor.AsyncProxyBeanPostProcessor;
import org.enhance.common.annotation.ConditionalOnProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

/**
 * 异步初始化自动配置
 *
 * @author wenpan 2023/06/11 17:11
 */
@ConditionalOnProperties(prefix = AsyncInitAutoConfiguration.PREFIX,
        properties = {"enable"}, values = {"true"}, matchIfMissing = false)
public class AsyncInitAutoConfiguration {

    public static final String PREFIX = "basis.enhance.async.init";

    @Bean
    @ConditionalOnMissingBean
    public AsyncInitBeanFactoryPostProcessor asyncInitBeanFactoryPostProcessor() {
        return new AsyncInitBeanFactoryPostProcessor();
    }

    @Bean
    @ConditionalOnMissingBean
    public AsyncProxyBeanPostProcessor asyncProxyBeanPostProcessor() {
        return new AsyncProxyBeanPostProcessor();
    }

    @Bean
    @ConditionalOnMissingBean
    public AsyncTaskExecutionListener asyncTaskExecutionListener() {
        return new AsyncTaskExecutionListener();
    }
}
